<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>日志分析</title>
    <link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='favicon.ico') }}">
    <link rel="stylesheet" type="text/css" href="../../static/admin/css/reset.css">
    <link rel="stylesheet" type="text/css" href="../../static/admin/css/main.css">
    <link rel="stylesheet" href="../../static/common/css/jquery.pagination.css">
    <script type="text/javascript" src="../../static/common/js/jquery-1.12.4.min.js"></script>
    <script type="text/javascript" src="../../static/common/js/jquery.pagination.min.js"></script>
</head>

<body>
<div class="breadcrub">
    日志管理 > 日志详情 > {{ data.log_name }}
    <form class="news_filter_form">
        <input type="text" placeholder="请求接口 关键词" name="keywords" value="{{ data.keywords }}" class="input_txt">
        <input type="submit" value="搜 索" class="input_sub">
        <input type="hidden" name="log_name" value="{{ data.log_name }}">
    </form>
</div>

<div class="pannel">

    <table class="common_table">

        {% if "error" in data.log_name %}
            <tr>
                <th width="10%">错误时间</th>
                <th width="5%">错误级别</th>
                <th width="20%">错误信息</th>
                <th width="10%">访客地址</th>
                <th width="10%">请求域名</th>
                <th width="5%">请求方法</th>
                <th width="15%">请求接口</th>
                <th width="5%">请求协议</th>
                <th width="20%">来源页面</th>
            </tr>

            {% for log in data.log_list %}
                <tr>
                    <td>{{ log.date_time }}</td>
                    <td>{{ log.level }}</td>
                    <td><input class="listmsg" disabled="true" value="{{ log.message }}"/></td>
                    <td>{{ log.ip }}</td>
                    <td>{{ log.host }}</td>
                    <td>{{ log.method }}</td>
                    <td><input class="listmsg" disabled="true" value="{{ log.url }}"/></td>
                    <td>{{ log.protocol }}</td>
                    <td><input class="listmsg" disabled="true" value="{{ log.referrer }}"/></td>
                </tr>
            {% endfor %}

        {% else %}
            <tr>
                <th width="10%">访客地址</th>
                <th width="10%">请求时间</th>
                <th width="5%">请求方法</th>
                <th width="20%">请求接口</th>
                <th width="5%">请求协议</th>
                <th width="5%">状态码</th>
                <th width="5%">流量(KB)</th>
                <th width="20%">来源页面</th>
                <th width="20%">设备信息</th>
            </tr>

            {% for log in data.log_list %}
                <tr>
                    <td>{{ log.ip }}</td>
                    <td>{{ log.date_time }}</td>
                    <td>{{ log.method }}</td>
                    <td><input class="listmsg" disabled="true" value="{{ log.url }}"/></td>
                    <td>{{ log.protocol }}</td>
                    <td>{{ log.status }}</td>
                    <td>{{ log.size }}</td>
                    <td><input class="listmsg" disabled="true" value="{{ log.referrer }}"/></td>
                    <td><input class="listmsg" disabled="true" value="{{ log.useragent }}"/></td>
                </tr>
            {% endfor %}

        {% endif %}
    </table>
</div>

<div class="box">
    <div id="pagination" class="page"></div>
</div>

<script>
    $(function () {
        $("#pagination").pagination({
            currentPage: {{ data.current_page }},
            totalPage: {{ data.total_page }},
            callback: function (current) {
                var keywords = $(" input[name='keywords'] ").val();
                var log_name = $(" input[name='log_name'] ").val();
                window.location = '/log_details?page=' + current + '&keywords=' + keywords + '&log_name=' + log_name
            }
        });
    });
</script>

</body>
</html>